const Sequelize = require('sequelize')
module.exports = function(sequelize, DataTypes, { sys_dept, sys_role }) {
  return sequelize.define('sys_role_dept', {
    role_id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: '角色ID',
      references: {
        model: sys_role, // 'Movies' 也可以使用
        key: 'role_id'
      }
    },
    dept_id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: '部门ID',
      references: {
        model: sys_dept, // 'Movies' 也可以使用
        key: 'dept_id'
      }
    }
  }, {
    sequelize,
    tableName: 'sys_role_dept',
    timestamps: false,
    indexes: [
      {
        name: 'PRIMARY',
        unique: true,
        using: 'BTREE',
        fields: [
          { name: 'role_id' },
          { name: 'dept_id' }
        ]
      }
    ]
  })
}
